import React from "react";
import { Upload, message, Button, Icon } from "antd";
import zhCN from "antd/lib/locale-provider/zh_CN";
import jaJP from "antd/lib/locale-provider/ja_jp";
import { DatePicker, LocaleProvider } from "antd";

const props = {
  name: "file",
  action: "//jsonplaceholder.typicode.com/posts/",
  onChange(info) {
    if (info.file.status !== "uploading") {
      console.log(info.file, info.fileList);
    }
    if (info.file.status === "done") {
      message.success(`${info.file.name} file uploaded successfully`);
    } else if (info.file.status === "error") {
      message.error(`${info.file.name} file upload failed.`);
    }
  }
};

export default class UploadPanel extends React.Component {
    state={
        lang:zhCN
    }
  render() {
    return (
      <div>
        <Upload {...props}>
          <Button>
            <Icon type="upload" /> Click to Upload
          </Button>
        </Upload>
        <LocaleProvider locale={this.state.lang}>
          <DatePicker />
        </LocaleProvider>
        <Button onClick={()=>this.setState({lang:jaJP})}>change lang to japanese</Button>
        <Button onClick={()=>this.setState({lang:zhCN})}>change lang to chinese</Button>
      </div>
    );
  }
}
